package com.cangli.service;


import com.cangli.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BookService {

    private List<Book> books = new ArrayList<>();
    private int usedSize = 1;

    public List<Book> getBooks() {
        return books;
    }

    public void addBook(String bookName, String bookAuthor) {
        books.add(new Book(usedSize++, bookName,bookAuthor));
    }

    public void removeBook(int id) {
        books.removeIf(book -> book.getId() == id);
    }

}
